package com.wf.ew.system.controller;

import com.wf.ew.common.BaseController;
import com.wf.ew.common.JsonResult;
import com.wf.ew.common.PageResult;
import com.wf.ew.system.model.Bug;
import com.wf.ew.system.service.BugService;
import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.IOException;
import net.sf.json.JSONArray;

/**
 *
 * controller
 * @author : Doman
 * @date : 2019-12-26 10:52:50
 * @version ：1.0
 */

@Controller
@RequestMapping("/system/bug")
public class BugController extends BaseController {

	@Autowired
	private BugService bugService;
	
	/**
	 * 页面
	 **/
	@RequiresPermissions("bug:view")
	@RequestMapping()
	public String bug() {
		return "system/bug.html";
	}

	/**
	 * 查询列表
	 */
	@RequiresPermissions("bug:view")
	@RequestMapping(value = "/list", produces = {"text/html;charset=UTF-8;"})
	@ResponseBody
	public String list(PageResult<T> page, Bug bug){
		return bugService.list(page, bug,getLoginUser());
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("bug:view")
	@RequestMapping(value = "/ajaxList", produces = {"text/html;charset=UTF-8;"})
	@ResponseBody
	public String ajaxList(Bug bug){
		return JSONArray.fromObject(bugService.list(bug,getLoginUser())).toString();
	}

	/**
	 * 新增
	 **/
	@RequiresPermissions("bug:add")
	@ResponseBody
	@RequestMapping("/add")
	public JsonResult add(Model model, Bug bug) {
		return bugService.add(bug, getLoginUser());
	}

	/**
	 * 修改
	 **/
	@RequiresPermissions("bug:update")
	@ResponseBody
	@RequestMapping("/update")
	public JsonResult update(Model model, Bug bug) {
		return bugService.update(bug, getLoginUser());
	}

	/**
	 * 批量删除
	 **/
	@RequiresPermissions("bug:delete")
	@RequestMapping("/delete")
	@ResponseBody
	public JsonResult delete(Bug bug ) {
		return bugService.delete(bug, getLoginUser());
	}

}
